package review;



public class MyCircularQueue {
    int[] queue;
    int front = -1;
    int rear = -1;
    int k ;
    public MyCircularQueue(int k) {
        queue = new int[k];
        this.k = k;
    }
    //插入
    public boolean enQueue(int value) {
        if (isFull()){
            return false;
        }

        return true;
    }

    //删除
    public boolean deQueue() {
        if (isEmpty()){
            return false;
        }

        front = ++front%k;
        return true;
    }

    public int Front() {
       return isEmpty()?-1:queue[front];
    }

    public int Rear() {
       return isEmpty()?-1:queue[rear];
    }


    //判断是否为空
    public boolean isEmpty() {
       return rear == front;
    }
    //判断是否为满
    public boolean isFull() {
        return (rear+1)%k == front;
    }
}
